import React, { Component } from "react";
import { Checkbox, Input } from "antd";
import styles from "./AuditPage.less";

const { TextArea } = Input;

class AuditPage extends Component {
  checkChange = e => {
    if (e && e.length === 2) {
      const { getCheck } = this.props;
      getCheck([e[1]]);
    } else {
      const { getCheck } = this.props;
      getCheck(e);
    }
  };

  render() {
    const { operate } = this.props;
    return (
      <div className={styles.auditInfo}>
        <div className={styles.title}>审批信息</div>
        <div className={styles.center}>
          <div className={styles.result}>
            审批结果：
            <Checkbox.Group
              disabled={operate === "detail"}
              value={this.props.checked}
              onChange={this.checkChange}
            >
              <Checkbox value={1}>通过</Checkbox>
              <Checkbox value={0}>不通过</Checkbox>
            </Checkbox.Group>
          </div>
          {this.props.checked.length > 0 && this.props.checked[0] === 0 ? (
            <div className={styles.advice}>
              审批意见：
              <TextArea
                style={{ width: 466, height: 120 }}
                disabled={operate === "detail"}
              />
            </div>
          ) : null}
        </div>
      </div>
    );
  }
}

export default AuditPage;
